//
// Created by 32827 on 2024/2/17.
//
#include "yzf_trng.h"
YZF_RESULT yzf_trng_enable(){
    TRNG_CTL |= TRNG_CTL_TRNGEN;
    return YZF_OK;
}
YZF_RESULT yzf_trng_disable(){
    TRNG_CTL &= ~TRNG_CTL_TRNGEN;
    return YZF_OK;
}
YZF_RESULT yzf_trng_ie_enable(){
    TRNG_CTL |= TRNG_CTL_TRNGIE;
    return YZF_OK;
}
YZF_RESULT yzf_trng_ie_disable(){
    TRNG_CTL &= ~TRNG_CTL_TRNGIE;
    return YZF_OK;
}
YZF_BOOL yzf_trng_flag_seed_error(){
    return (TRNG_STAT & TRNG_STAT_SEIF)!=0x0?YZF_TRUE:YZF_FALSE;
}
YZF_BOOL yzf_trng_flag_clock_error(){
    return (TRNG_STAT & TRNG_STAT_CEIF)!=0x0?YZF_TRUE:YZF_FALSE;
}
YZF_BOOL yzf_trng_flag_next_ready(){
    return (TRNG_STAT & TRNG_STAT_DRDY)!=0x0?YZF_TRUE:YZF_FALSE;
}
uint32_t yzf_trng_read(){
    return TRNG_DATA;
}